package com.command;

import java.text.SimpleDateFormat;
import java.util.Date;

public class EPSON {
	static StringBuffer sb=new StringBuffer();
	public String print(String layanan,String noantrian)
	{
		sb.replace(0, sb.length(), "");	
		//initialize
		sb.append(HexaToChar("1B"));
		sb.append(HexaToChar("40"));
		
		sb.append(HexaToChar("1B"));
		sb.append(HexaToChar("3D"));
		sb.append(HexaToChar("01"));
		
		sb.append(HexaToChar("1D"));
		sb.append(HexaToChar("49"));
		sb.append(HexaToChar("01"));
		
		//Logo
		sb.append(HexaToChar("1B"));
		sb.append(HexaToChar("40"));
		sb.append(HexaToChar("1C"));
		sb.append(HexaToChar("70"));
		sb.append(HexaToChar("01"));
		sb.append(HexaToChar("30"));
		//font size
		sb.append(HexaToChar("1D"));
		sb.append(HexaToChar("21"));
		sb.append(HexaToChar("01"));
		sb.append(HexaToChar("1D"));
		sb.append(HexaToChar("21"));
		sb.append(HexaToChar("10"));
		//GARIS BAWAH
		sb.append(HexaToChar("1B"));
		sb.append(HexaToChar("2D"));
		sb.append("1");
		//text align
		sb.append(HexaToChar("1B"));
		sb.append(HexaToChar("61"));
		sb.append("1");
		//text
		sb.append("NO ANTRIAN");
		sb.append("\r\n");
		//set font size
		sb.append(HexaToChar("1D"));
		sb.append(HexaToChar("21"));
		sb.append(HexaToChar("00"));
		sb.append(HexaToChar("1D"));
		sb.append(HexaToChar("21"));
		sb.append(HexaToChar("10"));
		//GARIS BAWAH
		sb.append(HexaToChar("1B"));
		sb.append(HexaToChar("2D"));
		sb.append("0");
		//text
		sb.append(layanan);
		//text
		sb.append(HexaToChar("1D"));
		sb.append(HexaToChar("21"));
		sb.append(HexaToChar("04"));
		sb.append(HexaToChar("1D"));
		sb.append(HexaToChar("21"));
		sb.append(HexaToChar("40"));
		sb.append("\r\n\r\n");
		sb.append(noantrian);
		sb.append("\r\n\r\n");
		//set font size
		sb.append(HexaToChar("1D"));
		sb.append(HexaToChar("21"));
		sb.append(HexaToChar("00"));
		sb.append(HexaToChar("1D"));
		sb.append(HexaToChar("21"));
		sb.append(HexaToChar("00"));
		sb.append("Silahkan tunggu, Terima kasih.");
		sb.append("\r\n");
		//text
		SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
		SimpleDateFormat sdf1 = new SimpleDateFormat("HH:mm:ss");
		sb.append(sdf.format(new Date()));
		sb.append(" -- ");
		sb.append(sdf1.format(new Date()));
		sb.append("\r\n\r\n");
		sb.append("\r\n\r\n");
		sb.append("\r\n\r\n");
		//auto cutter
		sb.append(HexaToChar("1B"));
		sb.append(HexaToChar("40"));
		sb.append(HexaToChar("1D"));
		sb.append(HexaToChar("56"));
		sb.append(HexaToChar("00"));
		
		return sb.toString();
	}
	
	private static char HexaToChar(String strHex)
	{
		int i= Integer.parseInt(strHex,16);
		char c = (char)i;
		return c;
	}  
}
